<template>
<div id="background">
    <el-container>
        <el-header id="tiMuHead">
            <el-row type="flex" style="height:80%;display:flex;align-items: flex-end">
                    <el-col :xs="3" :sm="3" :md="3" class="imgCol" >
                        <img v-bind:src="backIcon" class="backSize" @click="back" />
                    </el-col>
                    <el-col :xs="6" :sm="6" :md="6" :offset="6" class="imgCol">
                        <span class="titleSize">题库练习</span>
                    </el-col>
                    <el-col :xs="3" :sm="3" :md="3" class="imgCol" style="margin-left:15%;">
                        <img v-bind:src="biaoJi" class="biaoJi">
                    </el-col>
                    <el-col :xs="1" :sm="1" :md="1" class="imgCol">
                        <img v-bind:src="fenXiang" class="fenXiang">
                    </el-col>
                </el-row>
        </el-header>
        <el-main id="tiMuMain">
            <el-row style="padding-left:15px;width:16px;margin-top:15px;">
                 <img :src="daTiKa" class="daTiKa" style="margin-left:10px;" @click="showPopup">
            </el-row>
            <el-row type="flex" style="height:80px;" class="imgCol">
                <!-- <el-col style="width:20%;" class="dtkCol">
                    <img :src="daTiKa" class="daTiKa" style="margin-left:10px;" @click="showPopup">
                </el-col> -->
                <!-- <el-col style="width:80%;"> -->
                    <div style="position:relative">
                        <img :src="tiHaoQuan" class="tiHaoQuan">
                        <div style="position:absolute;top:26px;bottom:0;left:0px;right:0">
                            <span class="tiHao">
                                <span style="font-size:18px;font-weight:500;color:#707070;" class="imgCol">{{num}} <span style="font-size:16px;color:#b1b1b1;" >{{'/'+allNum}}</span></span>
                                <!-- <span style="font-size:16px;color:#b1b1b1;" >{{'/'+allNum}}</span> -->
                            </span> 
                        </div>
                    </div>
                <!-- </el-col> -->
            </el-row>
            <el-row >
                <el-row style="padding-left:15px;padding-right:15px;">
                    <el-card class="lxQuestion" :body-style="{ padding: '10px'}" shadow="always">
                        <el-row style="color:#707070;font-size:14px;">
                            {{questionText}}
                        </el-row>
                        <!-- <el-row class="lxAnswer" style="margin-top:10px;">
                           <el-input
                            type="textarea"
                            :autosize="{ minRows: 4, maxRows: 7}"
                            placeholder="请在此处答题"
                            v-model="lunShuNeiRong"
                            class="lunShuQuYu"
                            >
                        </el-input>
                        </el-row> -->
                    </el-card>
                </el-row>
            </el-row>
            <el-row class="jieXiPosition" v-show="jieXiShow">
                <el-row class="jieXiHead">
                    <span>解析</span>
                </el-row>
                <el-row class="jieXiContent">
                    <el-row>
                        {{'正确答案：'+answer}}
                    </el-row>
                    <el-row>
                        {{jieXi}}
                    </el-row>
                </el-row>
            </el-row>
            <el-row style="position:fixed;bottom:90px;width:100%" type="flex">
                        <el-col :xs="10" :sm="10" :md="10"  class="imgCol" >
                            <span style="color:#53cdf5" @click="shangti">上一题</span>
                        </el-col>
                        <el-col :xs="4" :sm="4" :md="4" class="imgCol">
                             <el-divider direction="vertical"></el-divider>
                        </el-col >
                        <el-col :xs="10" :sm="10" :md="10" class="imgCol"  >
                            <span style="color:#53cdf5" @click="xiati">下一题</span>
                        </el-col>
                </el-row>
            <van-popup
                v-model="show"
                position="bottom"
                :style="{ height: '250px' }"
            >
            <el-scrollbar>
                <div v-for="(value,index) in isCorrect" :key="index">
                    <el-col :xs="4" :sm="4" :md="4" class="imgCol">
                        <div v-if="value==true" class="yiZuo imgCol">
                            <div>
                                <span>{{index}}</span>
                                <img v-show="sign[index]" :src="biaoJi" class="biaoJiFu" style="height:10px;float: right;">
                            </div>
                        </div>
                        <div v-else-if="value==false" class="cuoWu imgCol">
                            <div>
                                <span>{{index}}</span>
                                <img v-show="sign[index]" :src="biaoJi" class="biaoJiFu" style="height:10px;float: right;">
                            </div>
                        </div>
                        <div v-else class="weiZuo imgCol">
                            <div>
                                <span>{{index}}</span>
                                <img v-show="sign[index]" :src="blueBiaoJi" class="biaoJiFu" style="height:10px;float: right;">
                            </div>
                        </div>
                    </el-col>
                </div>
            </el-scrollbar>
            </van-popup>
        </el-main>
        <!-- <el-footer id="tiMuFoot">
             <el-row type="flex" class="tj"> 
                    <button class="tjbtn"  @click="showJieXi"><p class="btnWords">提交</p></button>
            </el-row>
        </el-footer> -->
    </el-container>
    <div style="backgroundColor:#ffffff">
        <el-row type="flex" class="imgCol" style="position:fixed;bottom:10px;width:100%"> 
            <button class="tjbtn" @click="showJieXi"><p class="btnWords">提交</p></button>
        </el-row>
    </div>
</div>    
</template>

<script>
import blueBiaoJi from '../../assets/img/tiKu/blueBiaoJi.png'
import { Popup } from 'vant'
import backIcon from '../../assets/img/mine/back.png'
import biaoJi from '../../assets/img/tiKu/biaoJi.png'
import fenXiang from '../../assets/img/tiKu/fenXiang.png'
import daTiKa from '../../assets/img/tiKu/daTiKa.png'
import tiHaoQuan from '../../assets/img/tiKu/TiHaoQuan.png'
export default {
    data(){
        return{
           blueBiaoJi:blueBiaoJi,
            sign:[],
            isCorrect:[],
            show: false,
            lunShuNeiRong:'',
            jieXiShow:false,
            answer:'',
            jieXi:'',
            id:8,
            tiHaoQuan:tiHaoQuan,
            daTiKa:daTiKa,
            biaoJi:biaoJi,
            fenXiang:fenXiang,
            backIcon:backIcon,
            normalHeight:document.documentElement.clientHeight,
            num:1,
            allNum:'',
            questionText:'',
            bankId:'',
            type:'论述',
            pageNo:1,
            pageSize:1,
        }
    },
    mounted(){
        var id=this.$route.query.bankId;
        this.bankId=id;

        var bg = document.getElementById("background");
       // this.normalHeight=document.documentElement.clientHeight;
        console.log("height:"+this.normalHeight);
        bg.style.height = this.normalHeight+"px";
        bg.style.backgroundColor = "#FFFFFF"
        bg.style.margin = "0px";

        var head=document.getElementById("tiMuHead");
        var headHeight=this.normalHeight/30 *4 ;
        console.log("headHeight:"+headHeight);
        head.style.height=headHeight+"px";

        var main=document.getElementById("tiMuMain");
        var mainHeight=this.normalHeight/30 *23 ;
        main.style.height=mainHeight+"px";

        // var foot=document.getElementById("tiMuFoot");
        // var footHeight=this.normalHeight/30 *3 ;
        // foot.style.height=footHeight+"px";

        this.getTiMu();
        this.getDaTiKa();
    },
    methods:{
        getDaTiKa(){
            var URL=this.IP.IP+'/questionBank/questionBankCard';
            this.$ajax({
                    method:'get',
                    url:URL,
                    params: {
                       bankId:this.bankId,
                       type:this.type,
                    },
                }).then(response =>{
                  this.sign=response.data.data.sign;
                  this.isCorrect=response.data.data.isCorrect;
                  console.log(this.isCorrect);
                }).catch(error => {
                console.log('sad');
                });
        },
        showPopup() {
            this.show = true;
        },
        showJieXi(){
            this.jieXiShow=true;
            this.getAnswer();
        },
        getAnswer(){
            var URL=this.IP.IP+'/questionBank/questionAnalysis';
            this.$ajax({
                    method:'get',
                    url:URL,
                    params: {
                       id:this.id,
                       type:this.type,
                    },
                }).then(response =>{
                    this.answer=response.data.data.answer;
                    this.jieXi=response.data.data.analysis;
                console.log(response.data.data);
                }).catch(error => {
                console.log('sad');
                });
        },
        getTiMu(){
            var URL=this.IP.IP+'/questionBank/questionGet';
            this.$ajax({
                    method:'get',
                    url:URL,
                    params: {
                       bankId:this.bankId,
                       type:this.type,
                       pageNo:this.pageNo,
                       pageSize:this.pageSize,
                    },
                }).then(response =>{
                    this.allNum=response.data.data.total;
                    this.questionText=response.data.data.info[0].questionText;
                console.log(response.data.data);
                }).catch(error => {
                console.log('sad');
                });
        },
        // goDaTiKa(){
        //     this.$router.push({
        //         path:'/tiKu/lianXiDaTiKa'
        //     })
        // },
        back(){
            console.log("back:");
            this.$router.go(-1);
        },
        shangti(){
            if(this.num!=1){
                this.id--;
                this.num--;
                this.pageNo--;
                this.getTiMu();
            }else{
                console.log('已经是第一题了')
            }
        },
        xiati(){
            if(this.num<this.allNum){
                this.id++;
                this.jieXiShow=false;
                this.pageNo++;
                this.num++;
                this.getTiMu();
            }else{
                console.log('已经是最后一题了')
            }
        },
    }
}
</script>

<style>
.cuoWu{
    width:30px;
    height:30px;
    border-radius: 50%;
    background-color: #f16161;
    color: #fff; 
    border: #f16161 1px solid;
    margin-top:15px;
}
.yiZuo{
    width:30px;
    height:30px;
    border-radius: 50%;
    background-color: #53cdf5;
    color: #fff; 
    border: #53cdf5 1px solid;
    margin-top:15px;
}
.weiZuo{
    width:30px;
    height:30px;
    border-radius: 50%;
    background-color:#fff;
    color: #53cdf5;
    border: #53cdf5 1px solid; 
    margin-top:15px;
}
.dtkCol{
    display:flex;
    align-items:center;
    justify-content:center
}
.btnWords{
    font-size: 16px;
    color: #ffffff;
}
.tjbtn{
    line-height: 0.65em;
    width: 80%;
    background-color: #53cdf5;
    border-style: none;
    outline: none;
    -webkit-border-radius: 25px;
    -moz-border-radius: 25px;
    -ms-border-radius: 25px;
    -o-border-radius: 25px;
    border-radius: 25px;
}
.imgCol{
    display: flex;
    justify-content: center;
    align-items: center;
}
.dtkCol{
    display:flex;
    align-items:center;
    justify-content:center
}
.jieXiPosition{
    margin-top: 20px;
   padding-left: 15px;
    padding-right: 15px;
}
.jieXiHead{
    color: #707070;
    font-size: 15px;
    margin: 5px;
}
.jieXiContent{
    color: #707070;
    font-size: 14px;
}

.xz{
    margin-top: 10px;
}
.st{
    position: relative;
    left:8%;
}
.xt{
    position: absolute;
    left: 72%;
}
.lxQuestion{
    margin-top: 20px;
    border-radius: 10px;
}
.tiHaoQuan{
    height: 80px;
    width: 80px;
}
.daTiKa{
    /* position: relative;
    top:20px; */
    
    width:16px;
    height:16px;
}
.biaoJi{
    width:12px;
    height: 12px;
}
.fenXiang{
    width:12px;
    height: 12px;
}
#tiMuMain{
    padding: 0;
    background: #FFFFFF;
}
#tiMuHead {
  background-color: #53cdf5;
}
.backSize{
    height: 26px;
}
.titleSize{
    font-size:1.125em;
    color:#ffffff
}
@media screen and (max-height: 600px){
  .backSize{
      height: 22px;
  }
  .titleSize{
      font-size: 1em;
  }
}
</style>
